//
//  Lang.m
//  WIFI
//
//  Created by macbook on 2022/6/1.
//

#import "Lang.h"

@implementation Lang

/**
 获取当前App使用语言是否为中文
 */
+ (BOOL)languageIsChinese {
    NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
    NSArray  *array = [language componentsSeparatedByString:@"-"];
    NSString *currentLanguage = array[0];
    
    if (currentLanguage.length > 0 && [currentLanguage isEqualToString:@"zh"]) {
        return YES;
    }else {
        return NO;
    }
}

/**
 获取当前App使用语言
 */
+ (NSString *)language {
    
    NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
    NSArray  *array = [language componentsSeparatedByString:@"-"];
    NSString *currentLanguage = array[0];
    
    if (currentLanguage.length > 0 && [currentLanguage isEqualToString:@"zh"]) {
        //中文
        return @"zh";
    }else if (currentLanguage.length > 0 && [currentLanguage isEqualToString:@"ja"]) {
        //日文
        return @"ja";
    }else if (currentLanguage.length > 0 && [currentLanguage isEqualToString:@"ko"]) {
        //韩文
        return @"ko";
    }else if (currentLanguage.length > 0 && [currentLanguage isEqualToString:@"fil"]) {
        //菲律宾语
        return @"fil";
    }else {
        //英文
        return @"en";
    }
}

/**
 设置语言
 */
+ (NSString *)set:(NSString *)str {
    return NSLocalizedString(str,  nil);
}

@end
